#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5e4 + 5;

int n, m;
int head[N];
int ver[N << 1], Next[N << 1], tot;
void add(int u, int v) {
  ++tot;
  ver[tot] = v;
  Next[tot] = head[u];
  head[u] = tot;
}
int f[N][16], dep[N];
void dfs(int u, int fu) {
  dep[u] = dep[fu] + 1;
  f[u][0] = fu;
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fu) continue;
    dfs(v, u);
  }
}
void init() {
  dfs(1, 0);
  rep(j, 1, 15) rep(i, 1, n) f[i][j] = f[f[i][j - 1]][j - 1];
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int d = dep[u] - dep[v];
  per(j, 15, 0) if (d & (1 << j)) u = f[u][j];
  if (u == v) return u;
  per(j, 15, 0) if (f[u][j] != f[v][j]) u = f[u][j], v = f[v][j];
  return f[u][0];
}
int d[N], ans;
void dfs_sum(int u, int fu) {
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fu) continue;
    dfs_sum(v, u);
    d[u] += d[v];
  }
  ans = max(ans, d[u]);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 2, n) {
    int u, v;
    cin >> u >> v;
    add(u, v), add(v, u);
  }
  init();
  while (m--) {
    int u, v;
    cin >> u >> v;
    int x = lca(u, v);
    d[u]++, d[v]++;
    d[x]--, d[f[x][0]]--;
  }
  dfs_sum(1, 0);
  cout << ans;
  return 0;
}